package com.yyx.lgb.utils;

import com.yyx.lgb.model.entity.system.SysUser;
import com.yyx.lgb.model.entity.user.UserInfo;

/**
 * ClassName: AuthContextUtil
 * Package: com.yyx.lgb.utils
 * Description:
 *
 * @Author: yyx
 * @Create: 2025/8/1 - 9:12
 */
public class AuthContextUtil {

    private static  final  ThreadLocal<SysUser> THREAD_LOCAL=new ThreadLocal<>();
    private static final ThreadLocal<UserInfo> userInfoThreadLocal = new ThreadLocal<>() ;

    //定义存储数据的静态方法
    public static  void set(SysUser sysUser){
        THREAD_LOCAL.set(sysUser);
    }

    //定义获取数据的方法
    public static SysUser get(){
        return THREAD_LOCAL.get();
    }

    //删除数据的方法
    public static void remove(){
        THREAD_LOCAL.remove();
    }

    // 定义存储数据的静态方法
    public static void setUserInfo(UserInfo userInfo) {
        userInfoThreadLocal.set(userInfo);
    }

    // 定义获取数据的方法
    public static UserInfo getUserInfo() {
        return userInfoThreadLocal.get() ;
    }

    // 删除数据的方法
    public static void removeUserInfo() {
        userInfoThreadLocal.remove();
    }
}
